Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [DHIS2-18081] Problem with date format when scheduling an event #3816

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

henrikmv
Copy link
Contributor

@henrikmv henrikmv commented Sep 27, 2024

DHIS2-18081

  • Converts date to server format YYYY-MM-DD.
  • Format of date stored in the scheduleDate-state is based on the system settings.

@henrikmv henrikmv marked this pull request as ready for review September 27, 2024 13:39
@henrikmv henrikmv requested a review from a team as a code owner September 27, 2024 13:39
@eirikhaugstulen
Copy link
Contributor

Hey @henrikmv - I like the changes you've made here.

However, I think we should keep the scheduleDate-state in the same format as would be displayed in the input field. Right now, it's always stored in the server format. Can you take a look to see if you can get this state to store either YYYY-MM-DD or DD-MM-YYYY based on the system settings instead? This is what we're doing other places in the app. Let's have a chat about it tomorrow! 😊

@@ -45,13 +46,15 @@ export const WidgetEventSchedule = ({
});
const { currentUser, noteId } = useNoteDetails();
const [scheduleDate, setScheduleDate] = useState('');
const dateFormat = systemSettingsStore.get().dateFormat;
const formatDateForServer = date => moment(date, dateFormat).format('YYYY-MM-DD');
const formattedScheduleDate = formatDateForServer(scheduleDate);
Copy link
Contributor

@simonadomnisoru simonadomnisoru Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @henrikmv
Can you use existing converters instead, in the same way as is currently done elsewhere, i.e. getConvertedRelatedStageEvent?

const convertFn = pipe(convertFormToClient, convertClientToServer);
const serverScheduleDate = convertFn(scheduleDate, dataElementTypes.DATE);

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants